// qwqPlugin.java

package qwq.zyu;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import qwq.zyu.BingoSidebar.qwqBingoSidebarCommand;
import qwq.zyu.CommandblockScan.CommandblockScanner;
import qwq.zyu.EnterHint.qwqListener;
import qwq.zyu.Hologram.qwqRemoveHologramCommand;
import qwq.zyu.Hologram.qwqSetScheduledUpdateHologramCommand;
import qwq.zyu.Hologram.qwqShowTop10ScoreboardCommand;
import qwq.zyu.Scoreboard.qwqScheduledLoggingScoreboardCommand;
import qwq.zyu.Scoreboard.qwqOneshotScoreboardWriter;
import qwq.zyu.TeamColor.*;

import java.util.Objects;

public class qwqPlugin extends JavaPlugin {

    private final qwqScheduledLoggingScoreboardCommand obj_qwqScheduledLoggingScoreboardCommand = new qwqScheduledLoggingScoreboardCommand(this);
    private final qwqTeamColorCommand obj_qwqTeamColorCommand = new qwqTeamColorCommand(this, new qwqScheduledTeamColorTask());
    private final qwqShowTop10ScoreboardCommand obj_qwqShowTop10ScoreboardCommand = new qwqShowTop10ScoreboardCommand(this);

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new qwqListener(), this);
        Objects.requireNonNull(
                getCommand("qwq_write_scoreboard_2_txt_once")
        ).setExecutor(new qwqOneshotScoreboardWriter(this));

        Objects.requireNonNull(
                getCommand("qwq_set_scheduled_write_scoreboard_task")
        ).setExecutor(obj_qwqScheduledLoggingScoreboardCommand);

        Objects.requireNonNull(
            getCommand("qwq_set_scheduled_team_color_dye")
        ).setExecutor(obj_qwqTeamColorCommand);

        Objects.requireNonNull(
                getCommand("qwq_show_top10_scoreboard")
        ).setExecutor(new qwqShowTop10ScoreboardCommand(this));

        Objects.requireNonNull(
                getCommand("qwq_remove_hologram")
        ).setExecutor(new qwqRemoveHologramCommand());

        Objects.requireNonNull(
            getCommand("qwq_set_scheduled_update_scoreboard")
        ).setExecutor(new qwqSetScheduledUpdateHologramCommand(this, obj_qwqShowTop10ScoreboardCommand));

        Objects.requireNonNull(
            getCommand("scancommandblocks")
        ).setExecutor(new CommandblockScanner());

        Objects.requireNonNull(
            getCommand("qwq_bingo_sidebar")
        ).setExecutor(new qwqBingoSidebarCommand(this));
    }

    @Override
    public boolean onCommand(
            CommandSender sender,
            Command command,
            String label,
            String[] args
    ) {
        if (command.getName().equalsIgnoreCase("qwq")) {
            sender.sendMessage(
                    ChatColor.AQUA + "【qwq-spigot-plugin】" + ChatColor.RESET + "qwq!"
            );
            return true;
        } else {
            return super.onCommand(sender, command, label, args); // 使用默认的命令处理逻辑
        }
    }

    @Override
    public void onDisable() {
        obj_qwqScheduledLoggingScoreboardCommand.stopAllLogging();
    }
}